package com.br.sae.controls;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.br.sae.conexaobd.SistemaDAO;
import com.br.sae.model.dao.UsuarioBD;
import com.br.sae.model.entitys.Professor;
import com.br.sae.model.entitys.Usuario;

public class LogicaSetProfessor implements Logica{

	@Override
	public String executa(HttpServletRequest req, HttpServletResponse res)
			throws Exception {
		int id = Integer.valueOf(req.getParameter("id"));
		SistemaDAO sistemaDAO = new SistemaDAO();
		UsuarioBD usuarioBD = new UsuarioBD();
		Professor professor = (Professor) sistemaDAO.find(Professor.class, id);	
		Usuario usuario = usuarioBD.consultaUsuario(id, "Professor");
		
		req.setAttribute("professor", professor);
		req.setAttribute("usuario", usuario);
		
		return "cadastro_professor.jsp?Metodo=alterarProfessor";
	}
	
}
